

AddCSLuaFile()

ENT.Base 			= "base_nextbot"
ENT.Spawnable		= true

function ENT:Initialize()

	--self:SetModel( "models/props_halloween/ghost_no_hat.mdl" );
	--self:SetModel( "models/props_wasteland/controlroom_filecabinet002a.mdl" );
	self:SetModel( "models/mossman.mdl" );

end

function ENT:BehaveAct()

end

function Phrase(f)
local tab = {}
local content = file.Read(f)

local row = string.Explode( "\n", content )
for k,v in ipairs(row) do
	local line = string.Explode( " ", v)
	if(line[1] == "") then
	
	else
	table.insert(tab,Vector(line[1],line[2],line[3]))
	end
end

	

	return tab

end

function ENT:RunBehaviour()

	while ( true ) do

		-- walk somewhere random
		self:StartActivity( ACT_WALK )							-- walk anims
		self.loco:SetDesiredSpeed( 100 )	
		for k,v in ipairs(Phrase("path2.txt")) do
			for a,b in ipairs(ents.FindInSphere(v,500)) do
			Msg(b .. "\n")
		self:MoveToPos( b:GetPos() ) -- walk to a random place within about 200 units (yielding)
		end
	end
		self:StartActivity( ACT_IDLE )		-- revert to idle activity

		self:PlaySequenceAndWait( "idle_to_sit_ground" )							-- Sit on the floor
		self:SetSequence( "sit_ground" )											-- Stay sitting
		coroutine.wait( self:PlayScene( "scenes/eli_lab/mo_gowithalyx01.vcd" ) )	-- play a scene and wait for it to finish before progressing
		self:PlaySequenceAndWait( "sit_ground_to_idle" )							-- Get up
		
		-- find the furthest away hiding spot
		local pos = self:FindSpot( "random", { type = 'hiding', radius = 5000 } )

		-- if the position is valid
		if ( pos ) then
			self:StartActivity( ACT_RUN )											-- run anim
			self.loco:SetDesiredSpeed( 200 )										-- run speed
			self:PlayScene( "scenes/npc/female01/watchout.vcd" )					-- shout something while we run just for a laugh
			self:MoveToPos( pos )													-- move to position (yielding)
			self:PlaySequenceAndWait( "fear_reaction" )								-- play a fear animation
			self:StartActivity( ACT_IDLE )											-- when we finished, go into the idle anim
		else

			-- some activity to signify that we didn't find shit

		end

		coroutine.yield()

	end


end







--
-- List the NPC as spawnable
--
list.Set( "NPC", "Bones", 	{	Name = "Bones", 
										Class = "Bones",
										Category = "TF2"	
									})